package com.itheima.service.cmsService.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.cms.CmsPrefrenceAreaProductRelation;
import com.itheima.mapper.cmsMapper.CmsPrefrenceAreaProductRelationMapper;
import com.itheima.service.cmsService.CmsPrefrenceAreaProductRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class CmsPrefrenceAreaProductRelationServiceImpl implements CmsPrefrenceAreaProductRelationService {
    @Autowired
    CmsPrefrenceAreaProductRelationMapper cmsPrefrenceAreaProductRelationMapper;

    @Override
    public void add(CmsPrefrenceAreaProductRelation relation) {
        cmsPrefrenceAreaProductRelationMapper.insert(relation);
    }

    @Override
    public List<CmsPrefrenceAreaProductRelation> getInfoByBrandId(Long id) {
        LambdaQueryWrapper<CmsPrefrenceAreaProductRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CmsPrefrenceAreaProductRelation::getProductId,id);
        List<CmsPrefrenceAreaProductRelation> cmsPrefrenceAreaProductRelations = cmsPrefrenceAreaProductRelationMapper.selectList(lqw);
        return cmsPrefrenceAreaProductRelations;
    }

    @Override
    public void update(CmsPrefrenceAreaProductRelation relation) {
        cmsPrefrenceAreaProductRelationMapper.updateById(relation);
    }
}
